home *** CD-ROM | disk | FTP | other *** search
- /*
- *
- * STDIO.H Standard i/o include file
- *
- */
-
- #ifndef _STDIO_H
- #define _STDIO_H
-
- #ifndef _SIZE_T
- #define _SIZE_T
- typedef unsigned int size_t;
- #endif
-
- /*
- * CONSTANTS:
- */
- #ifndef NULL
- #define NULL ((void *)0)
- #endif
- #define NFILES (20) /* maximum number of open streams */
-
- #if 0
- #define ATEXIT_MIN 32
- /* Ansi says atleast 32 -- we make this dynamic */
- #endif
- #define BUFSIZ ((size_t)1024) /* default buffer size */
- /* change here must be reflected in crt0.c too */
-
- #define EOF (-1) /* end-of-file indicator */
- #define EOS '\0' /* end-of-string indicator */
- #define CMASK 0377
-
- /* lseek() origins */
- #define SEEK_SET 0 /* from beginning of file */
- #define SEEK_CUR 1 /* from current location */
- #define SEEK_END 2 /* from end of file */
-
- /* FILE structure flags */
- #define _IOREAD 0x0001 /* file may be read from */
- #define _IOWRT 0x0002 /* file may be written to */
- #define _IOBIN 0x0004 /* file is in "binary" mode */
- #define _IODEV 0x0008 /* file is a character device */
- #define _IORW 0x0080 /* file is open for update (r+w) */
- #define _IOFBF 0x0100 /* i/o is fully buffered */
- #define _IOLBF 0x0200 /* i/o is line buffered */
- #define _IONBF 0x0400 /* i/o is not buffered */
- #define _IOMYBUF 0x0800 /* standard buffer */
- #define _IOEOF 0x1000 /* EOF has been reached */
- #define _IOERR 0x4000 /* an error has occured */
- #define _IOSTRING 0x8000 /* really a string buffer */
-
- typedef struct /* FILE structure */
- {
- long _cnt; /* # of bytes in buffer */
- unsigned char *_ptr; /* current buffer pointer */
- unsigned char *_base; /* base of file buffer */
- unsigned int _flag; /* file status flags */
- int _file; /* file handle */
- long _bsiz; /* buffer size */
- unsigned char _ch; /* tiny buffer, for "unbuffered" i/o */
- }
- FILE;
-
- /* object of type capable of recording uniquely every position in a file */
- typedef unsigned long fpos_t;
-
- #define L_tmpnam 128
- #define TMP_MAX 100
-
- extern FILE _iob[];
-
- /* standard streams */
- #define stdin (&_iob[0])
- #define stdout (&_iob[1])
- #define stderr (&_iob[2])
-
- /* stream macros */
- #define clearerr(fp) ((void) ((fp)->_flag &= ~(_IOERR|_IOEOF)))
- #define feof(fp) ((fp)->_flag & _IOEOF)
- #define ferror(fp) ((fp)->_flag & _IOERR)
- #define fileno(fp) ((fp)->_file)
-
- /* aliases */
- #define getc(fp) (--(fp)->_cnt>=0? ((int)*(fp)->_ptr++):_filbuf(fp))
- #define ungetc fungetc
- #define putc fputc
- #define getchar() getc(stdin)
- #define ungetchar(c) fungetc((c),stdin)
- #define putchar(c) fputc((c),stdout)
-
- /* function definitions */
- #if ((defined(__STDC__)) && (!defined(__NO_PROTO__)))
-
- int remove(const char *);
- int rename(const char *, const char *);
- char *tmpnam(char *);
- FILE *tmpfile(void);
-
- int fclose(FILE *);
- int fflush(FILE *);
-
- FILE *fopen(const char *, const char *);
- FILE *freopen(const char *, const char *, FILE *);
-
- void setbuf(FILE *, char *);
- int setvbuf(FILE *, char *, int, size_t);
-
- #ifdef __SRC__
- int fprintf(FILE *, const char *, int);
- int printf(const char *, int);
- int sprintf(char *, const char *, int);
- int fscanf(FILE *, const char *, char *);
- int scanf(const char *, char *);
- int sscanf(const char *, const char *, int);
- #else
- int fprintf(FILE *, const char *, ...);
- int printf(const char *, ...);
- int sprintf(char *, const char *, ...);
- int fscanf(FILE *, const char *, ...);
- int scanf(const char *, ...);
- int sscanf(const char *, const char *, ...);
- #endif
-
- int vfprintf(FILE *, const char *, char *);
- int vprintf(const char *, char *);
- int vsprintf(char *, const char *, char *);
-
- int fgetc(FILE *);
- char *fgets(char *, int, FILE *);
- char *gets(char *);
- int fputc(int c, FILE *);
- int fputs(const char *, FILE *);
- int puts(const char *);
- int fungetc(int, FILE *);
-
- size_t fread(void *, size_t, size_t, FILE *);
- size_t fwrite(const void *, size_t, size_t, FILE *);
-
- int fgetpos(FILE *, fpos_t *);
- int fsetpos(FILE *, fpos_t *);
-
- int fseek(FILE *, long, int);
- long ftell(FILE *);
- void rewind(FILE *);
-
- void perror(const char *);
-
- long getl(FILE *);
- long putl(long, FILE *);
-
- int _filbuf(FILE *);
-
- #ifndef __STRICT_ANSI__
- FILE *fdopen(int, const char *);
- short getw(FILE *);
- short putw(short, FILE *);
- FILE *popen(const char *, const char *);
- int pclose(FILE *);
- #endif /* __STRICT_ANSI__ */
-
- #else
-
- extern char *tmpnam();
- extern FILE *tmpfile();
-
- extern FILE *fopen();
- extern FILE *freopen();
-
- extern void setbuf();
-
- extern char *fgets();
- extern char *gets();
-
- extern size_t fread();
- extern size_t fwrite();
-
- extern long ftell();
- extern void rewind();
-
- extern void perror();
-
- extern long getl();
- extern long putl();
-
- #ifndef __STRICT_ANSI__
- extern FILE *fdopen();
- extern FILE *popen();
- #endif
-
- #endif /* __STDC__ */
-
- #endif /* _STDIO_H */
-